const router = require('express').Router()
const M = require('kobako-maybe')
const U = require('../../utils')
const Shop = require('../../controllers/user-end/shop')

router.param('id',(req, res, next, id) => {

  id = M.maybe(id)

  if (M.isNothing(id)) {
    res.json(U.Err('您没有提供商店id'))
    return
  }

  req.shop_id = M.or(id, null)

  console.log('shop_id: ' + req.shop_id)

  next()
})

router.route('/:id')
  .get((req, res) => {
    res.json(U.Ok(Shop.all_foods(req.shop_id)))
  })

module.exports = router